草庐IT

C++ CreateWindowEx 返回 NULL

全部标签

c# - 空文本框是否被视为空字符串或 null?

有问题的文本框包含在我的代码中的if语句中,其效果为if(textbox.text!=""){dothis}我很好奇空文本框是否会被视为空字符串或空语句。 最佳答案 尝试使用IsNullOrWhiteSpace,这将确保验证空白,而无需修剪它。if(!string.IsNullOrWhiteSpace(textbox.Text)){//codehere}根据文档string.IsNullOrWhiteSpace计算为:returnString.IsNullOrEmpty(value)||value.Trim().Length==0;

c# - 单元测试返回 void 的方法

想在下面的类中对一个方法进行单元测试publicclassDeviceAuthorisationService:IDeviceAuthorisationService{privateDeviceDetailsDTOdeviceDetailsDTO=null;privateIDeviceAuthorisationRepositiorydeviceAuthorisationRepositiory;publicDeviceAuthorisationService(IDeviceAuthorisationRepositioryServiceparamDeviceAuthorisationRep

c# - ExternalLoginInfo 电子邮件在 Microsoft 和 Facebook oauth2、MVC C# 中始终为 null?

我正在为ExternalLoginCallback使用以下代码在google中一切正常。但在Facebook和Microsoft中,loginInfo.Email始终为空。以下代码有什么问题?[AllowAnonymous]publicasyncTaskExternalLoginCallback(stringreturnUrl){ExternalLoginInfologinInfo=awaitAuthenticationManager.GetExternalLoginInfoAsync();if(loginInfo==null){returnRedirectToAction("Logi

c# - 使用 LINQ 返回不同的 IQueryable?

我正在编写一个函数,该函数使用LINQ从数据库中提取记录以获取IQueryable。此LINQ语句将提取特定时间段内活跃用户的所有记录,然后将用户ID、名字和姓氏输出到TelerikRadGrid。我的问题在于在拉取此数据时尝试在UserID上获取不同的值。我尝试重新编写此代码以获得我的结果。这是提取所有数据的代码示例,其中Distinct不工作。publicstaticIQueryableGetActiveEmployees_Grid(stringPeriod){DataContextData=newDataContext();varEmployees=(fromcinDataSys

c# - 在输入 json 中将值 {null} 转换为类型 'System.DateTime' 时出错

当我尝试在我的Json中输入以下DateTime参数时抛出此JsonSerializationException:"Errorconvertingvalue{null}totype'System.DateTime'ininputjson"我在这里给出了输入:stringinputJSONString="{....,\"StartDateFrom\":null,\"StartDateTo\":null,\"EndDateFrom\":null,\"EndDateTo\":null,\....}";反序列化使用:scT=(SearchCriteriaTask)JsonConvert.Des

c# - mvc4 资源路由上的 miniprofiler 返回 404

我正在尝试从nuget和mvc4安装中设置miniprofiler、miniprofiler.mvc3和miniprofiler.ef,目标是.net4.0它注册了路由/mini-profiler-resources/{resourceName},当我使用routedebugger时,这条路由出现了。但是,对该路由的所有请求都以404返回。我运气不好是因为我正在运行mvc4还是这很奇怪?来自routedebugger(对格式化感到抱歉,想象它是一个表格!)AllRoutesMatchesCurrentRequestUrlDefaultsConstraintsDataTokensFals

c# - 返回可为空的字符串类型

所以我有这样的东西publicstring?SessionValue(stringkey){if(HttpContext.Current.Session[key].ToString()==null||HttpContext.Current.Session[key].ToString()=="")returnnull;returnHttpContext.Current.Session[key].ToString();}无法编译。如何返回可为null的字符串类型? 最佳答案 String已经是可以为null的类型。Nullable只能用

c# - GetLastWriteTime 返回 12/31/1600 7 :00:00 PM

我正在使用以下代码将目录的修改日期时间写入标签stringselectedPath=comboBox1.SelectedItem.ToString();DateTimelastdate=Directory.GetLastWriteTime(selectedPath);datemodified.Text=lastdate.ToString();它返回日期12/31/16007:00:00PM,我不知道它是从哪里得到那个日期的。任何人都可以帮助我理解为什么它返回那个日期以及我如何解决它?我正在使用.NET3.5 最佳答案 来自thedo

c# - Linq 返回字符串

我不确定为什么以下内容不以字符串形式返回Vend的值。当我检查vend的值时,它说:System.Data.Objects.ObjectQuery``1[System.String]stringvend=(fromvndindb.Vendorswherevnd.VendorID==idselectvnd.VendorName).ToString();当我查看vend的值时,它不是我所期望的 最佳答案 你得到一个IQueryable从你查询回来。您需要First或Single或其他东西:stringvend=(fromvndindb.

c# - out 用于多个输出值或返回组合值类型更好吗?

例如,按照以下行:publicboolIntersect(Rayray,outfloatdistance,outVector3normal){}对比publicIntersectResultIntersect(Rayray){}publicclassIntersectResult{publicboolIntersects{get;set;}publicfloatDistance{get;set;}publicVector3Normal{get;set;}}哪个在清晰度、易用性和最重要的性能方面更好。 最佳答案 我会使用组合类型,我会